package com.ailink.basic.proxy;

import java.lang.reflect.*;

public class TestProxy {
    public static void main(String[] args) throws NoSuchMethodException {
        ConcreteClass concreteClass = new ConcreteClass();
        Class<?>[] interfaces = concreteClass.getClass().getInterfaces();

//        Class<?> cl = Proxy.getProxyClass(TestProxy.class.getClassLoader(), new Class[] { JavaProxyInterface.class });
//        Class<?>[] interfaces1 = cl.getInterfaces();
//        System.out.println(cl.isInterface());
//        Method[] declaredMethods = cl.getDeclaredMethods();
//        Constructor<?>[] constructors = cl.getConstructors();
//        Class<?>[] constructorParams =
//                { InvocationHandler.class };
//        final Constructor<?> cons = cl.getConstructor(constructorParams);

        JavaProxyInterface newJavaProxyInterface = (JavaProxyInterface) Proxy.newProxyInstance(
                TestProxy.class.getClassLoader(), new Class[] { JavaProxyInterface.class },
                new MyInvocationHandler(concreteClass));
        newJavaProxyInterface.oneDay();
    }
}
